home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 February / SGI IRIX 6.5 Complementary Applications 2004 February.iso / dist / cde.idb / usr / dt / share / examples / dthelp / HelpCache.c.z / HelpCache.c
Encoding:
C/C++ Source or Header  |  2003-11-18  |  22.6 KB  |  850 lines

  1. /*
  2.  * HelpCache.c
  3.  * 
  4.  * Copyright 2000, Silicon Graphics, Inc.
  5.  * ALL RIGHTS RESERVED
  6.  * 
  7.  * UNPUBLISHED -- Rights reserved under the copyright laws of the United
  8.  * States.   Use of a copyright notice is precautionary only and does not
  9.  * imply publication or disclosure.
  10.  *
  11.  * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  12.  * Use, duplication or disclosure by the Government is subject to restrictions
  13.  * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  14.  * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  15.  * in similar or successor clauses in the FAR, or the DOD or NASA FAR
  16.  * Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  17.  * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  18.  *
  19.  * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  20.  * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  21.  * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  22.  * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  23.  * GRAPHICS, INC.
  24.  */
  25. /* $XConsortium: HelpCache.c /main/cde1_maint/1 1995/07/17 20:59:33 drk $ */
  26. /*************************************<+>*************************************
  27.  *****************************************************************************
  28.  **
  29.  **  File:        HelpCache.c
  30.  **
  31.  **  Project:       dthelpdemo demo program
  32.  **
  33.  **  Description: Contains the Help Callbacks and Utility functions for our
  34.  **               demo tool dthelpdemo.
  35.  **
  36.  **
  37.  **  (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994
  38.  **      Hewlett-Packard Company
  39.  **  (c) Copyright 1993, 1994 International Business Machines Corp.
  40.  **  (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  41.  **  (c) Copyright 1993, 1994 Unix System Labs, Inc., a subsidiary of
  42.  **      Novell, Inc.
  43.  **
  44.  ****************************************************************************
  45.  ************************************<+>*************************************/
  46.  
  47. /* System Include Files  */
  48.  
  49.  
  50. #include <Xm/Xm.h>
  51. #include <Xm/XmP.h>
  52.  
  53.  
  54. #include <Dt/Help.h>
  55. #include <Dt/HelpDialog.h>
  56. #include <Dt/HelpQuickD.h>
  57.  
  58. /* Local Includes */
  59. #include "Main.h"
  60. #include "HelpCacheI.h"
  61. #include "HourGlassI.h"
  62.  
  63.  
  64. /********    Static Function Declarations    ********/
  65.  
  66. #ifdef _NO_PROTO
  67. static void CloseHelpCB(); 
  68. static Boolean GetFromCache();
  69.  
  70. #else
  71.  
  72. static void CloseHelpCB (
  73.     Widget w,
  74.     XtPointer clientData,
  75.     XtPointer callData);
  76. static Boolean GetFromCache(
  77.     Widget parent,
  78.     CacheListStruct **pCurrentNode);
  79. #endif /* _NO_PROTO */
  80.  
  81.  
  82.  
  83. /* Global Main Help Dialog Widget */
  84. static Widget helpMain=NULL;
  85. static Widget versionMain=NULL;
  86.  
  87.  
  88. /*****************************************************************************
  89.  * Function:        void HelpMapCB()
  90.  *                   
  91.  *                            
  92.  *
  93.  * Parameters:      clientData is the widget in reference to
  94.  *                  which widget w is placed
  95.  *
  96.  * Return Value:    Void.
  97.  *
  98.  * Purpose:         Determins where a new child dialog should be mapped in
  99.  *                  relation to its parent.
  100.  *
  101.  * Algorithm:       1. attempt left or right placement with no overlap
  102.  *                  2. if fails, attempt up or down placement with no overlap
  103.  *                  3. if fails, determines location with least
  104.  *                     amount of overlap, and places there.
  105.  *
  106.  *****************************************************************************/
  107. XtCallbackProc HelpMapCB(
  108.     Widget w,
  109.     XtPointer clientData,
  110.     XtPointer callData)
  111.  
  112. {
  113.  
  114.     Arg         args[2];
  115.     Widget      parent;
  116.     Position    centeredY, bestX, bestY, pX, pY; 
  117.     Dimension   pHeight, myHeight, pWidth, myWidth;
  118.     Dimension   maxX, maxY;
  119.     int            rhsX, lhsX, topY, botY;   /* needs to be int, not Dimension */
  120.     Display *   display;
  121.     Screen *    screen;
  122.     int         screenNumber;
  123.  
  124.     parent = (Widget)clientData;
  125.     display = XtDisplay(w);
  126.     screen = XtScreen(w);
  127.     screenNumber = XScreenNumberOfScreen(screen);
  128.     pX = XtX(parent);
  129.     pY = XtY(parent);
  130.     if (pX < 0) pX = 0;
  131.     if (pY < 0) pY = 0;
  132.     pHeight = XtHeight(parent);
  133.     pWidth = XtWidth(parent);
  134.     myHeight = XtHeight(w);
  135.     myWidth = XtWidth(w);
  136.     maxX = XDisplayWidth(display,screenNumber);
  137.     maxY = XDisplayHeight(display,screenNumber);
  138.  
  139.     /* algorithm 
  140.      * 1. attempt left or right placement with no overlap
  141.      * 2. if fails, attempt up or down placement with no overlap
  142.      * 3. if fails, places on the right in the middle
  143.      */
  144.     
  145.     /* first try left right placement */
  146.     bestY = pY + pHeight/2 - myHeight/2;
  147.     centeredY = bestY;
  148.     rhsX = pX + pWidth;
  149.     lhsX = pX - myWidth - 8;     /* 8: account for border */
  150.     if ( (rhsX + myWidth) < maxX ) bestX = rhsX;
  151.     else if ( lhsX > 0 ) bestX = lhsX;
  152.     else
  153.     {
  154.           /* then try up down placement */
  155.         bestX = pX + pWidth/2 - myWidth/2;
  156.         botY = pY + pHeight;
  157.         topY = pY - myHeight - 44;     /* 44: account for menu border */
  158.         if ( (botY + myWidth) < maxY ) bestY = botY;
  159.         else if ( topY > 0 ) bestY = topY;
  160.         else
  161.         {
  162.             /* otherwise, center vertically and on the right */
  163.             bestX = maxX - myWidth;
  164.             bestY = centeredY;
  165.         }
  166.     }
  167.  
  168.     XtSetArg(args[0], XmNx, bestX);
  169.     XtSetArg(args[1], XmNy,  bestY);
  170.     XtSetValues(w, args, 2);
  171.  
  172.     return((XtCallbackProc) NULL);
  173.  
  174. }
  175.  
  176.  
  177. /****************************************************************************
  178.  * Function:         CloseHelpCB(
  179.  *                              Widget w,
  180.  *                              XtPointer clientData, 
  181.  *                          XtPointer callData
  182.  *
  183.  * Parameters:      
  184.  *
  185.  * Return Value:    Void.
  186.  *
  187.  * Purpose:         Process close requests on all Help Dialog widgets 
  188.  *                  created and managed by this application.
  189.  *
  190.  ***************************************************************************/
  191. #ifdef _NO_PROTO
  192. static void CloseHelpCB (w, clientData, callData) 
  193.     Widget        w;        /*  widget id        */
  194.     XtPointer        clientData;    /*  data from applicaiton   */
  195.     XtPointer         callData;    /*  data from widget class  */
  196. #else
  197. static void CloseHelpCB (
  198.     Widget w,
  199.     XtPointer clientData,
  200.     XtPointer callData)
  201. #endif /* _NO_PROTO */
  202. {
  203.  
  204.   Widget helpDialog = (Widget) clientData;
  205.  
  206.   CacheListStruct *pTemp; 
  207.  
  208.   pTemp = pCacheListHead;
  209.   
  210.   /* Search our Cache List for the closed help dialog */
  211.   while ((pTemp->helpDialog != helpDialog) && (pTemp != NULL))
  212.      pTemp = pTemp->pNext;
  213.  
  214.  
  215.   if (pTemp == NULL)
  216.     /* ERROR */
  217.     printf("We did not find our help dialog widget in the cache list??? /n");
  218.  
  219.   /* Un Map and Clean up the help widget */
  220.    XtUnmanageChild(helpDialog);
  221.   pTemp->inUseFlag  = FALSE;
  222.    
  223.  
  224. }
  225.  
  226.  
  227.  
  228. /****************************************************************************
  229.  * Function:         CloseMainCB(
  230.  *                              Widget w,
  231.  *                              XtPointer clientData, 
  232.  *                          XtPointer callData
  233.  *
  234.  * Parameters:      
  235.  *
  236.  * Return Value:    Void.
  237.  *
  238.  * Purpose:         Process close requests on our main help dialog.
  239.  *
  240.  ***************************************************************************/
  241. #ifdef _NO_PROTO
  242. static void CloseMainCB (w, clientData, callData) 
  243.     Widget        w;
  244.     XtPointer        clientData;
  245.     XtPointer         callData;
  246. #else
  247. static void CloseMainCB (
  248.     Widget w,
  249.     XtPointer clientData,
  250.     XtPointer callData)
  251. #endif /* _NO_PROTO */
  252. {
  253.    Widget currentDialog = (Widget) clientData;
  254.  
  255.  
  256.  
  257.   /* Un Map and Clean up the help widget */
  258.    XtUnmanageChild(currentDialog);
  259.  
  260. }
  261.  
  262.  
  263.  
  264.  
  265. /****************************************************************************
  266.  * Function:        void ProcessLinkCB(
  267.  *                              Widget w,
  268.  *                              XtPointer  clientData, 
  269.  *                          XtPointer callData
  270.  *
  271.  * Parameters:      
  272.  *
  273.  * Return Value:    Void.
  274.  *
  275.  * Purpose:         Process JUMP-NEW and APP-LINK hypertext requests in a 
  276.  *                  given Help Dialog Window.
  277.  *                 
  278.  *                  This is the callback used for the DtNhyperLinkCallback
  279.  *                  on each of the help dialog widges created.
  280.  *
  281.  ****************************************************************************/
  282. void ProcessLinkCB (
  283.     Widget w,
  284.     XtPointer clientData,
  285.     XtPointer callData)
  286.  
  287. {
  288.   Arg             args[20];
  289.   int             n;
  290.   Position          xPos, yPos;
  291.   int               appLinkNum=0;
  292.   int               count;
  293.   static Dimension  width=0;
  294.   static Dimension  height=0;
  295.   static Boolean    goBigger=TRUE;
  296.  
  297.   DtHelpDialogCallbackStruct * hyperData = 
  298.                          (DtHelpDialogCallbackStruct *) callData;
  299.   
  300.  
  301.   switch (hyperData->hyperType)
  302.     {
  303.       case DtHELP_LINK_JUMP_NEW:
  304.  
  305.         DisplayTopic (XtParent(w), hyperData->helpVolume,
  306.                       hyperData->locationId);
  307.         
  308.         break;
  309.  
  310.        case  DtHELP_LINK_MAN_PAGE:
  311.  
  312.          /* Create and display the requested man page */
  313.         DisplayMan(XtParent(w), hyperData->specification);
  314.  
  315.         
  316.          break;
  317.  
  318.       case  DtHELP_LINK_TEXT_FILE:
  319.  
  320.          /* Create a quick help dialog and display the text file in it */
  321.         
  322.          break;
  323.  
  324.        case  DtHELP_LINK_APP_DEFINE:
  325.  
  326.        appLinkNum = atoi(hyperData->specification);
  327.  
  328.       if (appLinkNum == 100)     /* Move the window */
  329.         {
  330.  
  331.           /* First Place the window in the upper left */
  332.           n = 0;
  333.           XtSetArg(args[n], XmNx, 0); ++n; 
  334.           XtSetArg(args[n], XmNy, 0); ++n;
  335.           XtSetValues(topLevel, args, n);
  336.         
  337.           /* Now move it down to the center of the display */
  338.  
  339.           for (count = 1;count < 500; count= count+5)
  340.             {
  341.               n = 0;
  342.               XtSetArg(args[n], XmNx, count); ++n; 
  343.               XtSetArg(args[n], XmNy, count); ++n;
  344.               XtSetValues(topLevel, args, n);
  345.               XmUpdateDisplay(topLevel);
  346.             }
  347.  
  348.         }
  349.  
  350.  
  351.       if (appLinkNum == 101)      /* Resize the window */
  352.         {
  353.  
  354.         if (width == 0)
  355.           {
  356.             /* Get the current dialog size */
  357.             n =0;
  358.             XtSetArg (args[n], XmNheight, &height);  n++;
  359.             XtSetArg (args[n], XmNwidth, &width);   n++;
  360.             XtGetValues(topLevel, args, n);
  361.           }
  362.  
  363.         if (goBigger)
  364.           {
  365.             n =0;
  366.             XtSetArg (args[n], XmNheight, height+100);  n++;
  367.             XtSetArg (args[n], XmNwidth, width+50);   n++;
  368.             XtSetValues(topLevel, args, n);
  369.             goBigger = FALSE;
  370.           }
  371.         else
  372.       {
  373.             /* Go smaller */
  374.             n =0;
  375.             XtSetArg (args[n], XmNheight, height);  n++;
  376.             XtSetArg (args[n], XmNwidth, width);   n++;
  377.             XtSetValues(topLevel, args, n);
  378.             goBigger = TRUE;
  379.           }
  380.  
  381.         }
  382.  
  383.  
  384.       if (appLinkNum == 102)  
  385.         {
  386.  
  387.     }
  388.  
  389.       if (appLinkNum == 103)  
  390.         {
  391.  
  392.         }
  393.  
  394.       break;
  395.  
  396.       default:  /* Catches any other  applicaion definded link types */
  397.  
  398.          printf("We some how got a bogus hyptertext link type/n");
  399.  
  400.  
  401.     }  /* End Switch Statement */
  402.  
  403. }
  404.  
  405.  
  406.  
  407.  
  408. /****************************************************************************
  409.  * Function:        void DisplayMan()
  410.  *
  411.  * Parameters:      
  412.  *
  413.  * Return Value:    Void.
  414.  *
  415.  * Purpose:         Displays a UNIX man page in a quick help dialog.
  416.  *
  417.  ****************************************************************************/
  418. void DisplayMan(
  419.     Widget  parent,
  420.     char    *man)
  421.  
  422. {
  423.  
  424.   Arg  args[20];
  425.   int    n;
  426.   Widget helpWidget;
  427.   char *title;
  428.  
  429.   XmUpdateDisplay(topLevel);
  430.  
  431.  
  432.  
  433.   if (manWidget == NULL)
  434.     {    
  435.       /* Create the QuickHelpDialog widget for help on help */
  436.       title = XtNewString(man);
  437.  
  438.       n =0;
  439.       XtSetArg (args[n], XmNuseAsyncGeometry, True);         n++;
  440.       XtSetArg (args[n], XmNtitle, title);                   n++;
  441.       XtSetArg (args[n], DtNhelpType,DtHELP_TYPE_MAN_PAGE); n++; 
  442.       XtSetArg (args[n], DtNmanPage, man);                   n++;
  443.       manWidget = DtCreateHelpQuickDialog(topLevel,"manBox", args, n);
  444.       XtFree((char*) title);
  445.  
  446.  
  447.       XtAddCallback(manWidget, DtNcloseCallback,
  448.                     CloseMainCB, (XtPointer) manWidget);
  449.  
  450.       /* Add the popup position callback to our man dialog */
  451.       XtAddCallback (XtParent(manWidget), XmNpopupCallback,
  452.                     (XtCallbackProc)HelpMapCB, 
  453.                     (XtPointer)topLevel);
  454.  
  455.  
  456.  
  457.  
  458.       /* We do not want a help button for now so we unmap it */     
  459.       helpWidget = DtHelpQuickDialogGetChild (manWidget,
  460.                               DtHELP_QUICK_HELP_BUTTON);
  461.       XtUnmanageChild (helpWidget);
  462.  
  463.       XtManageChild(manWidget);  
  464.     }
  465.   else
  466.     {
  467.        TurnOnHourGlass(manWidget);
  468.   
  469.        /* We already have a quick help dialog so re-use it */
  470.        n = 0;
  471.        XtSetArg (args[n], DtNhelpType,DtHELP_TYPE_MAN_PAGE); n++; 
  472.        XtSetArg (args[n], DtNmanPage, man);                   n++;
  473.      
  474.        XtSetValues(manWidget, args, n);
  475.        
  476.  
  477.        title = XtNewString(man);
  478.        n = 0;
  479.        XtSetArg (args[n], XmNtitle, title);                   n++;
  480.        XtSetValues(XtParent(manWidget), args, n);
  481.        XtFree((char*) title);
  482.  
  483.        XtManageChild(manWidget); 
  484.        XtMapWidget(XtParent(manWidget));    
  485.        XRaiseWindow(XtDisplay(parent), XtWindow(XtParent(manWidget)));
  486.        TurnOffHourGlass(manWidget);       
  487.  
  488.      }
  489.  
  490. }
  491.  
  492.   
  493. /****************************************************************************
  494.  * Function:        void DisplayTopic(
  495.  *                              Widget parent,
  496.  *                              char *helpVolume,
  497.  *                              char *locationId)
  498.  *
  499.  * Parameters:      
  500.  *
  501.  * Return Value:    Void.
  502.  *
  503.  * Purpose:         Creats and displays a new help dialog w/the requested help
  504.  *                  volume and topic.
  505.  *
  506.  ****************************************************************************/
  507. void DisplayTopic(
  508.     Widget  parent,
  509.     char    *helpVolume,
  510.     char    *locationId)
  511.  
  512. {
  513.   Arg         args[10];    
  514.   int           n;
  515.  
  516.  CacheListStruct *pCurrentNode = NULL;
  517.   Boolean       cachedNode = FALSE;
  518.  
  519.  
  520.   /* Get a inuse node if we have one or a Cached one */
  521.   cachedNode = GetFromCache(parent, &pCurrentNode);
  522.  
  523.  
  524.   /* If we got a free one from the Cache, use it */
  525.   /* Set Values on current free one, then map it */
  526.   if (cachedNode)
  527.     {
  528.        n = 0;
  529.        XtSetArg (args[n], XmNtitle, "HelpDemo Help");          n++;
  530.        if (helpVolume != NULL)
  531.          {
  532.            XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
  533.          }
  534.        XtSetArg (args[n], DtNlocationId,locationId);        n++;
  535.        XtSetValues(pCurrentNode->helpDialog, args, n);
  536.   
  537.        XtManageChild(pCurrentNode->helpDialog);    
  538.        XtMapWidget(XtParent(pCurrentNode->helpDialog));
  539.      }
  540.    else
  541.      {
  542.        while (!XtIsSubclass(parent, applicationShellWidgetClass))
  543.          parent = XtParent(parent);
  544.      
  545.  
  546.  
  547.         /* Build a new one in our cached list */
  548.         n = 0;
  549.         XtSetArg (args[n], XmNtitle, "Helpdemo Help");          n++;
  550.        if (helpVolume != NULL)
  551.          {
  552.            XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
  553.          }
  554.         XtSetArg (args[n], DtNlocationId,locationId);        n++;
  555.         pCurrentNode->helpDialog =  
  556.                    DtCreateHelpDialog(parent, "helpWidget", args, n);
  557.  
  558.  
  559.         XtAddCallback(pCurrentNode->helpDialog, DtNhyperLinkCallback,
  560.                        ProcessLinkCB, NULL);
  561.              
  562.         XtAddCallback(pCurrentNode->helpDialog, DtNcloseCallback,
  563.                       CloseHelpCB, (XtPointer) pCurrentNode->helpDialog);
  564.  
  565.         XtManageChild(pCurrentNode->helpDialog);    
  566.         XtMapWidget(XtParent(pCurrentNode->helpDialog));
  567.      }
  568. }
  569.  
  570.  
  571.  
  572.  
  573.  
  574. /****************************************************************************
  575.  * Function:        void DisplayMain(
  576.  *                              Widget parent,
  577.  *                              char *helpVolume,
  578.  *                              char *locationId)
  579.  *
  580.  * Parameters:      
  581.  *
  582.  * Return Value:    Void.
  583.  *
  584.  * Purpose:         Displays help for helpdemo in the one helpDialog window 
  585.  *                  created for the applicaiton.
  586.  *
  587.  ****************************************************************************/
  588. void DisplayMain (
  589.     Widget  parent,
  590.     char    *helpVolume,
  591.     char    *locationId)
  592.  
  593. {
  594.   Arg         args[10];    
  595.   int           n;
  596.  
  597.   if (helpMain != NULL)
  598.     {
  599.        n = 0;
  600.        XtSetArg (args[n], XmNtitle, "hemodemo Help");          n++;
  601.        if (helpVolume != NULL)
  602.          {
  603.            XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
  604.          }
  605.        XtSetArg (args[n], DtNlocationId,locationId);        n++;
  606.        XtSetValues(helpMain, args, n);
  607.   
  608.        XtManageChild(helpMain);    
  609.        
  610.      }
  611.    else
  612.      {
  613.        while (!XtIsSubclass(parent, applicationShellWidgetClass))
  614.          parent = XtParent(parent);
  615.      
  616.  
  617.         /* Build a new one in our cached list */
  618.         n = 0;
  619.         XtSetArg (args[n], XmNtitle, "Helpdemo Help");       n++;
  620.        if (helpVolume != NULL)
  621.          {
  622.            XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
  623.          }
  624.         XtSetArg (args[n], DtNlocationId,locationId);        n++;
  625.         helpMain = DtCreateHelpDialog(parent, "helpWidget", args, n);
  626.  
  627.         XtAddCallback(helpMain, DtNhyperLinkCallback,
  628.                        ProcessLinkCB, NULL);
  629.              
  630.         XtAddCallback(helpMain, DtNcloseCallback,
  631.                       CloseMainCB, (XtPointer) helpMain);
  632.  
  633.         /* Add the popup position callback to our main help dialog */
  634.         XtAddCallback (XtParent(helpMain), XmNpopupCallback,
  635.                         (XtCallbackProc)HelpMapCB, 
  636.                         (XtPointer)parent);
  637.  
  638.         XtManageChild(helpMain);    
  639.         
  640.      }
  641. }
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648. /****************************************************************************
  649.  * Function:        void DisplayVersion(
  650.  *                              Widget parent,
  651.  *                              char *helpVolume,
  652.  *                              char *locationId)
  653.  *
  654.  * Parameters:      
  655.  *
  656.  * Return Value:    Void.
  657.  *
  658.  * Purpose:         Displays the version dialog for the helpdemo program.
  659.  *
  660.  ****************************************************************************/
  661. void DisplayVersion (
  662.     Widget  parent,
  663.     char    *helpVolume,
  664.     char    *locationId)
  665.  
  666. {
  667.   Arg         args[10];    
  668.   int           n;
  669.   Widget        printWidget;
  670.   Widget        helpWidget;
  671.   Widget        backWidget;
  672.  
  673.  
  674.   if (versionMain != NULL)
  675.     {
  676.        n = 0;
  677.        XtSetArg (args[n], XmNtitle, "Helpdemo Version Dialog");          n++;
  678.        if (helpVolume != NULL)
  679.          {
  680.            XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
  681.          }
  682.        XtSetArg (args[n], DtNlocationId,locationId);        n++;
  683.        XtSetValues(versionMain, args, n);
  684.   
  685.        XtManageChild(versionMain);    
  686.        
  687.      }
  688.    else
  689.      {
  690.        while (!XtIsSubclass(parent, applicationShellWidgetClass))
  691.          parent = XtParent(parent);
  692.      
  693.  
  694.         /* Build a new one in our cached list */
  695.         n = 0;
  696.         XtSetArg (args[n], XmNtitle, "Helpdemo Version Dialog");       n++;
  697.        if (helpVolume != NULL)
  698.          {
  699.            XtSetArg (args[n],DtNhelpVolume,helpVolume);     n++; 
  700.          }
  701.         XtSetArg (args[n], DtNlocationId,locationId);        n++;
  702.     XtSetArg (args[n], DtNhelpType, DtHELP_TYPE_TOPIC);  n++;
  703.         versionMain = DtCreateHelpQuickDialog(parent,"versionWidget",args,n);
  704.  
  705.         XtAddCallback(versionMain, DtNcloseCallback,
  706.                       CloseMainCB, (XtPointer) versionMain);
  707.  
  708.  
  709.         /* We do not want a print button for now so we unmap it */     
  710.         printWidget = DtHelpQuickDialogGetChild (versionMain, 
  711.                                          DtHELP_QUICK_PRINT_BUTTON);
  712.         XtUnmanageChild (printWidget);
  713.   
  714.  
  715.         /* We do not want a help button for now so we unmap it */     
  716.         helpWidget = DtHelpQuickDialogGetChild (versionMain, 
  717.                                         DtHELP_QUICK_HELP_BUTTON);
  718.         XtUnmanageChild (helpWidget);
  719.   
  720.         backWidget = DtHelpQuickDialogGetChild (versionMain, 
  721.                                         DtHELP_QUICK_BACK_BUTTON);
  722.         XtUnmanageChild (backWidget);
  723.  
  724.         XtManageChild(versionMain);    
  725.         
  726.      }
  727. }
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734. /****************************************************************************
  735.  * Function:        static CacheListStruct GetFromCache(
  736.  *                                  Widget parent);
  737.  *
  738.  * Parameters:      
  739.  *
  740.  * Return Value:    Void.
  741.  *
  742.  * Purpose:         Gets a free help node form our cache list.  If none are
  743.  *                  free, it will return fallse and the calling routine will
  744.  *                  create a new help dialog widget.
  745.  *
  746.  ****************************************************************************/
  747. #ifdef _NO_PROTO
  748. static Boolean GetFromCache(parent, pCurrentNode)
  749.     Widget parent;
  750.     CacheListStruct **pCurrentNode;
  751. #else
  752. static Boolean GetFromCache(
  753.     Widget parent,
  754.     CacheListStruct **pCurrentNode)
  755. #endif /* _NO_PROTO */
  756.  
  757. {
  758.  
  759.   CacheListStruct *pTemp; 
  760.  
  761.   if (pCacheListHead == NULL)
  762.     {
  763.        /* We have a new list so lets create one and pass it back */
  764.        pCacheListHead = 
  765.                 (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
  766.  
  767.        /* Assign the default values to our node */
  768.        pCacheListHead->helpDialog = NULL;
  769.        pCacheListHead->inUseFlag  = TRUE;
  770.        pCacheListHead->pNext      = NULL;
  771.        pCacheListHead->pPrevious = NULL;
  772.  
  773.        /* Assign our tale pointer */
  774.        pCacheListTale = pCacheListHead;
  775.  
  776.        /* Make sure or totalNodes counter is correct, e.g. force it to 1 */
  777.        totalCacheNodes = 1;
  778.     
  779.        /* Return our head pointer because it's our first and only node */
  780.        *pCurrentNode = pCacheListHead;
  781.        return (FALSE);
  782.  
  783.     }
  784.   else
  785.     { 
  786.        /* We have need for an in-use help dialog or a new one, so look */
  787.        pTemp = pCacheListHead;
  788.       
  789.        while (pTemp != NULL)
  790.          {
  791.            if (pTemp->inUseFlag == FALSE)
  792.              {
  793.                 pTemp->inUseFlag = TRUE;
  794.                 *pCurrentNode = pTemp;
  795.                 return (TRUE);
  796.           }
  797.            else
  798.              pTemp = pTemp->pNext;
  799.      }
  800.       
  801.  
  802.        /* If we did not find a free nod then we must add a new one to the
  803.         * top of the list, and return it.
  804.         */
  805.  
  806.        pTemp =  (CacheListStruct *) XtMalloc((sizeof(CacheListStruct)));
  807.  
  808.        /* Assign the default values to our node */
  809.        pTemp->helpDialog = NULL;
  810.        pTemp->inUseFlag  = TRUE;
  811.      
  812.        pTemp->pNext      = pCacheListHead;
  813.        pTemp->pPrevious  = NULL;
  814.  
  815.        pCacheListHead->pPrevious = pTemp;
  816.  
  817.        /* Re-Assign our head pointer to point to the new head of the list */
  818.        pCacheListHead = pTemp;
  819.  
  820.        /* Make sure or totalNodes counter is correct, e.g. force it to 1 */
  821.        totalCacheNodes = totalCacheNodes + 1;
  822.  
  823.        /* Return our head pointer because it's our new node */
  824.        *pCurrentNode = pCacheListHead;
  825.        return (FALSE);
  826.  
  827.      }
  828.   
  829.  
  830. }
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.